package com.imooc.security.demo.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @author JackYang
 * @description:
 * @create: 2020/6/14 8:33
 */
//@Aspect
//@Component
public class TimeAspect {
    
    @Around("execution(* com.spring_security.demo.controller.*.*(..))")
    public Object handlerControllerMethod(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("---------------aspect start");
        Object[] objects = pjp.getArgs();
        System.out.println("---------------当前方法携带的参数信息如下");
        for (Object object : objects) {
            System.out.println("---------------"+object);
        }
        long starter = System.currentTimeMillis();
        Object object = pjp.proceed();
        System.out.println("---------------aspect end，共耗时："+(System.currentTimeMillis()-starter));
        return object;
    }
}
